package com.study.funny.grpc;

import com.study.funny.lib.HelloWorldProto;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.server.service.GrpcService;

/**
 * @ClassName: HelloGrpc
 * @Description: grpc 处理
 * @Author: funny
 * @CreateTime: 2025-01-05 22:10
 * @Version: 1.0
 **/
@Slf4j
@GrpcService
public class HelloGrpc extends com.study.funny.lib.HelloGrpc.HelloImplBase{
    @Override
    public void sayHello(HelloWorldProto.HelloRequest request, StreamObserver<HelloWorldProto.HelloReply> responseObserver) {
        log.info("接收到客户端的消息:{}",request);
        String message = "Hello " + request.getName();
        final HelloWorldProto.HelloReply.Builder replyBuilder = HelloWorldProto.HelloReply.newBuilder().setResult(message);
        responseObserver.onNext(replyBuilder.build());
        responseObserver.onCompleted();
        log.info("Returning " + message);
    }
}
